package torchtools;

import itemrecovertool.*;

/**
 * "Item" describes a generic item object -- not specific items from a player's
 * inventory. 
 * 
 * @author Matt
 */
public class Item {
    public final String NAME;
    public final String DISPLAYNAME;
    public final String PATH;
    public final String SET;
    public String UNITTYPE;
    public String UNITTYPE_PREFIX;
    
    int colorID = 0; 
    //0 normal (white)
    //1 magic/rare (blue)
    //2 magic/rare (blue)
    //3 unique (gold)
    //4 set (purple)
    
    private final String[] TYPE_PREFIXES = {"NORMAL", "MAGIC", 
                                          "RANDOMMAGIC", "UNIQUE"};

    public Item(String name, String displayname, String unittype, String path, String set) {
        NAME = name;
        DISPLAYNAME = displayname;
        PATH = path;
        SET = set;
        
        if (unittype!=null) {
            for (int i=0; i<TYPE_PREFIXES.length; i++) {
                String pre = TYPE_PREFIXES[i];
                if (unittype.startsWith(pre)) {
                    UNITTYPE = unittype.substring(pre.length()+1);
                    UNITTYPE_PREFIX = unittype.substring(0, pre.length()+1);
                    colorID = i;
                    break;
                }
            }
        } 
        if (UNITTYPE==null) {
            UNITTYPE = unittype;
            UNITTYPE_PREFIX = "NORMAL";
        }
        if (SET!=null)
            colorID = 4;
        if (UNITTYPE.equals("QUESTITEM"))
            colorID = 3;
    }

    public String toString() {
        return DISPLAYNAME+" ["+UNITTYPE+"]";
    }
}
